<template>
	<view>
		<u-cell-group>
			<u-cell title="工程名称" :label="mydata.Name"></u-cell>
			<u-cell title="所属项目" :label="mydata.ProjInfo?mydata.ProjInfo.Name:mydata.ProjName1st"></u-cell>
			<u-cell title="工程编号" :label="mydata.No"></u-cell>
			<u-cell title="建设单位" :label="mydata.FirstUnit"></u-cell>
			<u-cell title="施工单位" :label="mydata.SecondUnit"></u-cell>
			<u-cell title="工程性质" :label="mydata.BuildProperty"></u-cell>
			<u-cell title="工程类别" :label="mydata.BuildType"></u-cell>

			<u-cell title="工程工期" :label="mydata.LimitTime"></u-cell>
			<u-cell title="工程状态" :label="mydata.Status"></u-cell>
			<u-cell title="甲方状态" :label="mydata.Status1st"></u-cell>
			<u-cell title="开始时间" :label="mydata.StartTime"></u-cell>
			<u-cell title="预计完成时间" :label="mydata.PlanEndTime"></u-cell>
			<u-cell title="施工方负责人" :label="mydata.ProjManager"></u-cell>
			<u-cell title="施工人员" :label="mydata.Safer"></u-cell>
			<u-cell title="施工内容" :label="mydata.BuildContent"></u-cell>
			<u-cell title="工程地址" :label="mydata.Addr" isLink @click="gomap"></u-cell>
		</u-cell-group>
		<filelist :outid="buildid"></filelist>
	</view>
</template>

<script>
	import {
		getbuildlist
	} from '@/common/api.js'
	import coordtransform from 'coordtransform'
	import filelist from "../index/c_filelist.vue"
	export default {
		components: {
			filelist
		},
		props: {
			buildid: {}
		},
		watch: {

			buildid: {

				handler(newv, oldv) {
					this.getdate()

				}

			}

		},
		data() {
			return {

				mydata: {
					Name: '无',
					Addr: '',
					ProjInfo: {
						Name: ''
					},
					BuildManager: ""
				}
			}
		},
		onLoad(option) {
			// this.buildid = option.buildid
			// if (option.buildid)

		},
		mounted() {
			this.getdate()
		},

		methods: {
			showmap() {
				uni.navigateTo({
					url: 'map?buildid=' + this.buildid
				})
			},
			gomap() {
				if (this.mydata.Latlon) {
					let latitude = parseFloat( this.mydata.Latlon.split(',')[0])
					let longitude = parseFloat( this.mydata.Latlon.split(',')[1])
					var lola=coordtransform.wgs84togcj02(longitude,latitude)
					uni.openLocation({
						latitude: lola[1] ,
						longitude: lola[0],
						success: function() {
							console.log('success');
						}
					});
				}
			},
			getdate() {
				if (!this.buildid)
					return
				let para = {
					Parameters: [],
				}

				para.Parameters.push({
					FieldName: "Id",
					ConditionalType: "Equal",
					FieldValue: this.buildid
				})
				// this.mydata={Name:'22',Addr:'',ProjInfo:{Name:''},BuildManager:""}
				getbuildlist(para).then(res => {
					// this.mydata={Name:'33',Addr:'',ProjInfo:{Name:''},BuildManager:""}
					// console.log(this.data)
					this.mydata = res.data[0];
					// console.log(this.data)
				})
			}
		}
	}
</script>

<style>

</style>